#define _CRT_SECURE_NO_WARNINGS 1
int min(int x1, int x2)
{
    return x1 < x2 ? x1 : x2;
}


int minCostClimbingStairs(int* cost, int costSize) {
    int n = costSize;
    int* dp = (int*)malloc(sizeof(int) * n);
    dp[n - 1] = cost[n - 1];
    dp[n - 2] = cost[n - 2];

    if (n < 2)
        return 0;
    for (int i = n - 3; i >= 0; i--)
    {
        dp[i] = min(dp[i + 1], dp[i + 2]) + cost[i];
    }
    return dp[1] < dp[0] ? dp[1] : dp[0];
    free(dp);
}